var notIsRefreshing = false;
function refreshNot(URL_VIEW_LAST_MESSAGE) {
	var DATA = {};
	DATA['lastNotificationTS'] = $('#allNotifications').children().first().attr(
			'data-ts');

	if (DATA['lastNotificationTS'] == null || DATA['lastNotificationTS'] == '')
		DATA['lastNotificationTS'] = 0;

	if (!notIsRefreshing) {
		notIsRefreshing = true;
		$.ajax({
			type : 'post',
			url : URL_VIEW_LAST_MESSAGE,
			data : DATA,
			cache : false,
			success : function(data) {
				console.log(data);
				$('#allNotifications').prepend(data);
			},
			error : function(jqXHR, textStatus, errorThrown) {
				console.log("Error: " + textStatus);
			},
			complete : function(jqXHR, textStatus) {
				notIsRefreshing = false;
			}
		});
	}
}

function startRefreshNot(URL_VIEW_LAST_MESSAGE) {
	setInterval("refreshNot('" + URL_VIEW_LAST_MESSAGE + "');", 1000);
}

